package com.ikun.service.impl;

import com.ikun.mapper.ShoppingCartMapper;
import com.ikun.pojo.ShoppingCart;
import com.ikun.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoppingCartServiceImpl implements ShoppingCartService {
    @Autowired
    ShoppingCartMapper shoppingCartMapper;
    @Override
    /**
     *
     * 根据businessId与uerId查询购物车
     *
     */
    public List<ShoppingCart> getShoppingCartByBusinessIdAndUserId(Integer businessId, Integer userId) {
        return shoppingCartMapper.getShoppingCartIdByBusinessIdAndUserId(businessId, userId);
    }

    @Override
    public int addShoppingCart(Integer userId, Integer businessId, Integer quantity, Integer dishesId) {
        return shoppingCartMapper.addShoppingCart(userId, businessId, quantity,dishesId);
    }

    @Override
    public int updateQuantityByUserIdAndBusinessIdAndDishesId(Integer userId, Integer businessId, Integer dishesId, Integer quantity) {
        return shoppingCartMapper.updateQuantityByUserIdAndBusinessIdAndDishesId(userId, businessId,dishesId,quantity);
    }

    @Override
    public int deleteShoppingCartByUserIdAndBusinessIdAndDishesId(Integer userId, Integer businessId, Integer dishesId) {
        return shoppingCartMapper.deleteShoppingCartByUserIdAndBusinessIdAndDishesId(
                userId,businessId,dishesId
        );
    }
}
